using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter09
{
	/// <summary>
	/// Example10: Collision at an Intersection
	/// A 1,500 kg car traveling east with a speed of 25.0 m/s 
	/// collides at an intersection with a 2,500 kg van traveling 
	/// north at a speed of 20.0 m/s, as shown in Figure 9.14. 
	/// Find the direction and magnitude of the velocity  of 
	/// the wreckage after the collision, assuming that the 
	/// vehicles undergo a perfectly inelastic collision 
	/// (that is, they stick together).
	/// \theta = 53.1^{\circle}
	/// v_f = 15.6 m/s
	/// </summary>
	public class Example10
	{
		public Example10()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass car = new L.Mass();
			car.kg = 1500.0;
			L.Velocity vcar = new L.Velocity();
			vcar.X = 25.0;
			L.Mass van = new L.Mass();
			van.kg = 2500.0;
			L.Velocity vvan = new L.Velocity();
			vvan.Y = 20.0;
			L.Momentum[] pi = new L.Momentum[2];
			pi[0] = new L.Momentum(car,vcar);
			pi[1] = new L.Momentum(van,vvan);
			L.Mass ma = new L.Mass();
			ma.kg = car.kg + van.kg;
			L.Velocity v = new L.Velocity();
			v.XVariableQ = true;
			v.YVariableQ = true;
			L.Momentum pf = new L.Momentum(ma,v);
			L.FundamentalLaw.MomentumConservation(pi,pf);
            v.X = pf.X/ma.kg;
			v.Y = pf.Y/ma.kg;
			result+=Convert.ToString(Math.Atan(v.Y/v.X)
				*180.0/Math.PI)+"\r\n";
			result+=Convert.ToString(v.X)+"\r\n";
			result+=Convert.ToString(v.Y)+"\r\n";
			result+=Convert.ToString(v.mPERs)+"\r\n";
		}
	}
}
